package world0.gui;

import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.geom.Polygon;
import org.newdawn.slick.geom.Shape;

public abstract class Widget {

	protected int x;
	protected int y;
	protected int width;
	protected int height;
	protected String name;
	protected Color color;
	protected Polygon area;
	protected int index;
	
	public Widget(String name, int x, int y, int width, int height) {
		this.name = name;
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
	}
	
	public Widget(int index, int x, int y, int width, int height) {
		this.index = index;
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
	}
	
	protected void createFrame() {
		area = new Polygon();
		area.addPoint(0, 0);
		area.addPoint(width, 0);
		area.addPoint(width, height);
		area.addPoint(0, height);
		area.setLocation(x, y);
	}
	
	protected void draw(Graphics g) {
		g.setColor(color);
		g.fill(area);
	}
	
	public Shape getShape() {
		return area;
	}
	
	public int getX() {
		return x;
	}

	public int getY() {
		return y;		
	}

	public void setColor(Color color) {
		this.color = color;
	}
}
